package com.grass.p019lv.novel.activity;

import android.view.View;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.p015ui.LazyFragment;
import com.androidx.p013lv.base.utils.UiUtils;
import com.google.android.material.tabs.TabLayout;
import com.grass.p019lv.databinding.ActivityAudioBookMainBinding;
import com.grass.p019lv.novel.fragment.AudioBookFragment;
import com.grass.p019lv.novel.fragment.FictionFragment;
import com.gyf.immersionbar.ImmersionBar;
import java.util.ArrayList;
import java.util.List;

/* renamed from: com.grass.lv.novel.activity.AudioBookActivity */
public class AudioBookActivity extends BaseActivity<ActivityAudioBookMainBinding> {
    private FragmentStatePagerAdapter adapter;
    private List<LazyFragment> fragments = new ArrayList();
    private List<String> tabTitles = new ArrayList();
    int type;

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return R.layout.activity_audio_book_main;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityAudioBookMainBinding) this.binding).toolBar).init();
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        initTabLayout();
        initViewPager();
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initData() {
        super.initData();
        ((ActivityAudioBookMainBinding) this.binding).imgBack.setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.novel.activity.AudioBookActivity.View$OnClickListenerC30561 */

            public void onClick(View view) {
                AudioBookActivity.this.finish();
            }
        });
    }

    private void initViewPager() {
        this.type = getIntent().getIntExtra("pageType", 0);
        this.tabTitles.clear();
        this.fragments.clear();
        this.adapter = new MyAdapter(getSupportFragmentManager());
        ((ActivityAudioBookMainBinding) this.binding).viewPager.setAdapter(this.adapter);
        this.tabTitles.add("成人小說");
        this.fragments.add(0, FictionFragment.newInstance());
        this.tabTitles.add("有聲讀物");
        this.fragments.add(1, AudioBookFragment.newInstance());
        ((ActivityAudioBookMainBinding) this.binding).tabLayout.setupWithViewPager(((ActivityAudioBookMainBinding) this.binding).viewPager);
        ((ActivityAudioBookMainBinding) this.binding).viewPager.setCurrentItem(this.type);
        this.adapter.notifyDataSetChanged();
    }

    private void initTabLayout() {
        ((ActivityAudioBookMainBinding) this.binding).tabLayout.addOnTabSelectedListener((TabLayout.OnTabSelectedListener) new TabLayout.OnTabSelectedListener() {
            /* class com.grass.p019lv.novel.activity.AudioBookActivity.C30572 */

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabReselected(TabLayout.Tab tab) {
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabSelected(TabLayout.Tab tab) {
                AudioBookActivity.this.changeTabTextView(tab, true);
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabUnselected(TabLayout.Tab tab) {
                AudioBookActivity.this.changeTabTextView(tab, false);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void changeTabTextView(TabLayout.Tab tab, boolean z) {
        if (tab.getCustomView() == null) {
            tab.setCustomView(R.layout.tab_layout_text_invention);
        }
        TextView textView = (TextView) tab.getCustomView().findViewById(16908308);
        if (z) {
            textView.setPadding(0, 0, 0, 0);
            textView.setTextAppearance(this, R.style.TabLayoutAttentionTextSize);
            return;
        }
        textView.setPadding(0, 0, 0, UiUtils.dp2px(4));
        textView.setTextAppearance(this, R.style.TabLayoutNormalAttentionTextSize);
    }

    /* access modifiers changed from: package-private */
    /* renamed from: com.grass.lv.novel.activity.AudioBookActivity$MyAdapter */
    public class MyAdapter extends FragmentStatePagerAdapter {
        private MyAdapter(FragmentManager fragmentManager) {
            super(fragmentManager, 1);
        }

        @Override // androidx.fragment.app.FragmentStatePagerAdapter
        public Fragment getItem(int i) {
            return (Fragment) AudioBookActivity.this.fragments.get(i);
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public int getCount() {
            return AudioBookActivity.this.fragments.size();
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public CharSequence getPageTitle(int i) {
            return (CharSequence) AudioBookActivity.this.tabTitles.get(i);
        }
    }
}
